package com.mdx.zhizhao.service;

import com.mdx.zhizhao.domain.Enterprise;
import com.mdx.zhizhao.persistence.EnterpriseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class EnterpriseService {
    @Autowired
    private EnterpriseMapper enterpriseMapper;
    public void signup(Enterprise enterprise){
        Long count = enterpriseMapper.selectCount(null);
        String s=String.valueOf(count+1);
        enterprise.setEnterpriseid(s);
        enterpriseMapper.insert(enterprise);
    }
    public void updateEnterprise(Enterprise enterprise){
        enterpriseMapper.updateById(enterprise);
    }
    public Enterprise selectEnterprise(String enterpriseId){
        return enterpriseMapper.selectById(enterpriseId);
    }
    public Enterprise login(String id ,String pwd){
        Enterprise enterprise = enterpriseMapper.selectById(id);
        if(Objects.equals(pwd, enterprise.getEnterprisepassword())){
            return enterprise;
        }else{
            return null;
        }
    }



}
